package server.update;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

import server.port.manager.PortManager;

public class UpdateMain implements Runnable{

	public void run() {
		ServerSocket updateServerSocket = null;
		Socket updateSocket = null;
		try {
			updateServerSocket = new ServerSocket(PortManager.UPDATE_PORT);
			updateSocket = null;
			Thread updateThread = null;
			while(true){
				System.out.println("update main 대기중 : ");
				updateSocket = updateServerSocket.accept();
				updateThread = new Thread(new UpdateService(updateSocket));
				updateThread.start();
			}
		} catch (IOException ioe) {
			ioe.printStackTrace();
		} finally{
			try{
				if(updateSocket!=null){
					updateSocket.close();
				}
				if(updateServerSocket!=null){
					updateServerSocket.close();
				}
			}catch(IOException ioe){
				ioe.printStackTrace();
			}
		}
	}
}
